﻿/*
==============================================================================
//  公司信息维护页面控制层代码。
==============================================================================
*/

(function ($) {
    if (!window.platform) { window.platform = new Object(); }
    if (!window.platform.UserForm) { window.platform.UserForm = new Object(); }

    window.platform.UserForm.initPage = function (formid,roleid) {

        var _form = $("#" + formid);

        var _key = $("#ID", _form).val();

        var _bindControl = function () {

            if (_key == "0") {
                $("#UserName", _form).validatebox({ required: true });
                $("#UserName", _form).validatebox({
                    validType: 'remote["/User/AjaxCheckAddUserNotExist","UserName"]'
                });
            }
            else {
                $("#UserName", _form).attr("readonly", "readonly");
                $("#UserName", _form).addClass("BigStatic");

            }
            $("#SortNumber", _form).validatebox({ required: true, validType: ['integer'] });

        };
        var _bindRoleCombobox = function () {
            $('#SysRoleID', _form).combobox({
                url: "/Role/RoleList",

                valueField: "id",
                textField: "text",
                width: 200,
                required: true,

                onLoadSuccess: function () {
                    var defaultclassid = $("#SysRoleID", _form).combobox("getData");
                    
                    if (defaultclassid.length > 0) {
                        if (roleid != -1) {
                            $('#SysRoleID', _form).combobox("setValue", roleid);

                        }
                    }
                }
            });
        };
        _bindControl();
        _bindRoleCombobox();

    };
})(jQuery);